<template>
  <div class="api-page">
    <!-- 背景层 -->
    <div class="background-overlay" style="background-color: rgb(5, 150, 105);"></div>
    
    <div class="content-container">
      <!-- 加载状态 -->
      <div v-if="loading" class="loading">
        加载中...
      </div>
      
      <!-- 错误提示 -->
      <div v-else-if="error" class="error">
        {{ error }}
      </div>
      
      <!-- 数据展示 -->
      <div v-else class="data-container">
        <h1 class="title">API 数据</h1>
        
        <!-- 根据实际数据结构来展示 -->
        <div v-if="Array.isArray(apiData)" class="data-list">
          <div v-for="(item, index) in apiData" 
               :key="index"
               class="data-item">
            <!-- 根据实际数据结构调整显示内容 -->
            <pre>{{ JSON.stringify(item, null, 2) }}</pre>
          </div>
        </div>
        <div v-else class="data-single">
          <pre>{{ JSON.stringify(apiData, null, 2) }}</pre>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { cardService } from '@/services/cardService'
export default {
  data() {
    return {
      apiData: null
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      const response = cardService.getCard(1)
      this.apiData = response.data
    }
  }
}
</script>

<style scoped>
.api-page {
  position: relative;
  min-height: 100vh;
}

.background-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
}

.content-container {
  position: relative;
  z-index: 1;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.loading {
  text-align: center;
  padding: 40px;
  font-size: 18px;
  color: white;
}

.error {
  text-align: center;
  padding: 20px;
  color: #ff4444;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  margin: 20px;
}

.title {
  color: white;
  font-size: 24px;
  margin-bottom: 20px;
  text-align: center;
}

.data-container {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.data-list {
  display: grid;
  gap: 20px;
}

.data-item {
  background: white;
  padding: 15px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  font-family: monospace;
}
</style> 